home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / JRootPane.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  5.7 KB  |  224 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.IllegalComponentStateException;
  6. import java.awt.LayoutManager;
  7. import javax.accessibility.Accessible;
  8. import javax.accessibility.AccessibleContext;
  9.  
  10. public class JRootPane extends JComponent implements Accessible {
  11.    protected JMenuBar menuBar;
  12.    protected Container contentPane;
  13.    protected JLayeredPane layeredPane;
  14.    protected Component glassPane;
  15.    protected JButton defaultButton;
  16.    protected DefaultAction defaultPressAction;
  17.    protected DefaultAction defaultReleaseAction;
  18.  
  19.    public JRootPane() {
  20.       this.setGlassPane(this.createGlassPane());
  21.       this.setLayeredPane(this.createLayeredPane());
  22.       this.setContentPane(this.createContentPane());
  23.       ((Container)this).setLayout(this.createRootLayout());
  24.       ((JComponent)this).setDoubleBuffered(true);
  25.    }
  26.  
  27.    protected void addImpl(Component var1, Object var2, int var3) {
  28.       super.addImpl(var1, var2, var3);
  29.       if (this.glassPane != null && this.glassPane.getParent() == this && ((Container)this).getComponent(0) != this.glassPane) {
  30.          ((Container)this).add(this.glassPane, 0);
  31.       }
  32.  
  33.    }
  34.  
  35.    public void addNotify() {
  36.       SystemEventQueueUtilities.addRunnableCanvas(this);
  37.       super.addNotify();
  38.       ((Component)this).enableEvents(8L);
  39.    }
  40.  
  41.    protected Container createContentPane() {
  42.       JPanel var1 = new JPanel();
  43.       ((Component)var1).setName(((Component)this).getName() + ".contentPane");
  44.       ((Container)var1).setLayout(new 1());
  45.       return var1;
  46.    }
  47.  
  48.    protected Component createGlassPane() {
  49.       JPanel var1 = new JPanel();
  50.       ((Component)var1).setName(((Component)this).getName() + ".glassPane");
  51.       ((JComponent)var1).setVisible(false);
  52.       ((JPanel)var1).setOpaque(false);
  53.       return var1;
  54.    }
  55.  
  56.    protected JLayeredPane createLayeredPane() {
  57.       JLayeredPane var1 = new JLayeredPane();
  58.       ((Component)var1).setName(((Component)this).getName() + ".layeredPane");
  59.       return var1;
  60.    }
  61.  
  62.    protected LayoutManager createRootLayout() {
  63.       return new RootLayout(this);
  64.    }
  65.  
  66.    public AccessibleContext getAccessibleContext() {
  67.       if (super.accessibleContext == null) {
  68.          super.accessibleContext = new AccessibleJRootPane(this);
  69.       }
  70.  
  71.       return super.accessibleContext;
  72.    }
  73.  
  74.    public Container getContentPane() {
  75.       return this.contentPane;
  76.    }
  77.  
  78.    public JButton getDefaultButton() {
  79.       return this.defaultButton;
  80.    }
  81.  
  82.    public Component getGlassPane() {
  83.       return this.glassPane;
  84.    }
  85.  
  86.    public JMenuBar getJMenuBar() {
  87.       return this.menuBar;
  88.    }
  89.  
  90.    public JLayeredPane getLayeredPane() {
  91.       return this.layeredPane;
  92.    }
  93.  
  94.    /** @deprecated */
  95.    public JMenuBar getMenuBar() {
  96.       return this.menuBar;
  97.    }
  98.  
  99.    public boolean isFocusCycleRoot() {
  100.       return true;
  101.    }
  102.  
  103.    public boolean isValidateRoot() {
  104.       return true;
  105.    }
  106.  
  107.    protected String paramString() {
  108.       return super.paramString();
  109.    }
  110.  
  111.    public void removeNotify() {
  112.       SystemEventQueueUtilities.removeRunnableCanvas(this);
  113.       super.removeNotify();
  114.    }
  115.  
  116.    public void setContentPane(Container var1) {
  117.       if (var1 == null) {
  118.          throw new IllegalComponentStateException("contentPane cannot be set to null.");
  119.       } else {
  120.          if (this.contentPane != null && this.contentPane.getParent() == this.layeredPane) {
  121.             this.layeredPane.remove(this.contentPane);
  122.          }
  123.  
  124.          this.contentPane = var1;
  125.          this.layeredPane.add(this.contentPane, JLayeredPane.FRAME_CONTENT_LAYER);
  126.       }
  127.    }
  128.  
  129.    public void setDefaultButton(JButton var1) {
  130.       JButton var2 = this.defaultButton;
  131.       if (var2 != var1) {
  132.          this.defaultButton = var1;
  133.          if (var1 != null) {
  134.             if (this.defaultPressAction == null) {
  135.                this.defaultPressAction = new DefaultAction(this, true);
  136.                this.defaultReleaseAction = new DefaultAction(this, false);
  137.                ((JComponent)this).registerKeyboardAction(this.defaultPressAction, KeyStroke.getKeyStroke(10, 0, false), 2);
  138.                ((JComponent)this).registerKeyboardAction(this.defaultReleaseAction, KeyStroke.getKeyStroke(10, 0, true), 2);
  139.                ((JComponent)this).registerKeyboardAction(this.defaultPressAction, KeyStroke.getKeyStroke(10, 2, false), 2);
  140.                ((JComponent)this).registerKeyboardAction(this.defaultReleaseAction, KeyStroke.getKeyStroke(10, 2, true), 2);
  141.             }
  142.  
  143.             this.defaultPressAction.setOwner(var1);
  144.             this.defaultReleaseAction.setOwner(var1);
  145.          } else {
  146.             ((JComponent)this).unregisterKeyboardAction(KeyStroke.getKeyStroke(10, 0, false));
  147.             ((JComponent)this).unregisterKeyboardAction(KeyStroke.getKeyStroke(10, 0, true));
  148.             ((JComponent)this).unregisterKeyboardAction(KeyStroke.getKeyStroke(10, 2, false));
  149.             ((JComponent)this).unregisterKeyboardAction(KeyStroke.getKeyStroke(10, 2, true));
  150.             this.defaultPressAction = null;
  151.             this.defaultReleaseAction = null;
  152.          }
  153.  
  154.          if (var2 != null) {
  155.             ((Component)var2).repaint();
  156.          }
  157.  
  158.          if (var1 != null) {
  159.             ((Component)var1).repaint();
  160.          }
  161.       }
  162.  
  163.       ((JComponent)this).firePropertyChange("defaultButton", var2, var1);
  164.    }
  165.  
  166.    public void setGlassPane(Component var1) {
  167.       if (var1 == null) {
  168.          throw new NullPointerException("glassPane cannot be set to null.");
  169.       } else {
  170.          boolean var2 = false;
  171.          if (this.glassPane != null && this.glassPane.getParent() == this) {
  172.             ((Container)this).remove(this.glassPane);
  173.             var2 = this.glassPane.isVisible();
  174.          }
  175.  
  176.          var1.setVisible(var2);
  177.          this.glassPane = var1;
  178.          ((Container)this).add(this.glassPane, 0);
  179.          if (var2) {
  180.             ((Component)this).repaint();
  181.          }
  182.  
  183.       }
  184.    }
  185.  
  186.    public void setJMenuBar(JMenuBar var1) {
  187.       if (this.menuBar != null && this.menuBar.getParent() == this.layeredPane) {
  188.          this.layeredPane.remove(this.menuBar);
  189.       }
  190.  
  191.       this.menuBar = var1;
  192.       if (this.menuBar != null) {
  193.          this.layeredPane.add(this.menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
  194.       }
  195.  
  196.    }
  197.  
  198.    public void setLayeredPane(JLayeredPane var1) {
  199.       if (var1 == null) {
  200.          throw new IllegalComponentStateException("layeredPane cannot be set to null.");
  201.       } else {
  202.          if (this.layeredPane != null && this.layeredPane.getParent() == this) {
  203.             ((Container)this).remove(this.layeredPane);
  204.          }
  205.  
  206.          this.layeredPane = var1;
  207.          ((Container)this).add(this.layeredPane, -1);
  208.       }
  209.    }
  210.  
  211.    /** @deprecated */
  212.    public void setMenuBar(JMenuBar var1) {
  213.       if (this.menuBar != null && this.menuBar.getParent() == this.layeredPane) {
  214.          this.layeredPane.remove(this.menuBar);
  215.       }
  216.  
  217.       this.menuBar = var1;
  218.       if (this.menuBar != null) {
  219.          this.layeredPane.add(this.menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
  220.       }
  221.  
  222.    }
  223. }
  224.